package vip.liux.front.infrastructure.tenant;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.stereotype.Component;

import static vip.liux.front.infrastructure.tenant.TenantContext.TENANT_ID;

@Component
public class TenantRequestInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate requestTemplate) {
        // 从当前线程中获取租户信息
        String tenantId = TenantContext.getCurrentTenant();
        // 将租户信息添加到请求头中
        requestTemplate.header(TENANT_ID, tenantId);
    }
}
